package com.usian.admin.controller;

import com.usian.admin.service.AdChannelService;
import com.usian.api.admin.AdChannelControllerApi;
import com.usian.model.admin.dtos.ChannelDto;
import com.usian.model.admin.pojos.AdChannel;
import com.usian.model.common.dtos.ResponseResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 文件名： AdChannelController
 * 创作者： 闫俊涛
 *
 * @version 1.0
 * @Date 2022/6/26 16:02
 * @注释
 */
@RestController
@RequestMapping("/api/admin/v1/channel")
public class AdChannelController  implements AdChannelControllerApi {

    @Autowired
    private AdChannelService adChannelService;

    @PostMapping("/list")
    @Override
    public ResponseResult findByNameAndPage(ChannelDto dto) {
        return adChannelService.findByNameAndPage(dto);
    }

    @PostMapping("/save")
    @Override
    public ResponseResult save(@RequestBody AdChannel channel) {
        return adChannelService.insert(channel);
    }

    @PostMapping("/update")
    @Override
    public ResponseResult update(@RequestBody AdChannel adChannel) {
        return adChannelService.update(adChannel);
    }

    @GetMapping("/del/{id}")
    @Override
    public ResponseResult deleteById(@PathVariable("id") Integer id) {
        return adChannelService.deleteById(id);
    }


}